function a(a) {
    return a && a.__esModule ? a : {
        default: a
    };
}

a(require("../../utils/underscore"));

var t = a(require("../../utils/requestUtil")), r = require("../../utils/data"), e = a(r), i = (a(require("../../utils/functionData")), 
a(require("../../utils/util")), a(require("../../utils/dg")));

a(require("../../utils/plugUtil")), a(require("../../wxParse/wxParse")), a(require("../../utils/listener")), 
getApp();

Page({
    ad: {
        timerId: 0
    },
    data: {
        dgGlobal_options: null,
        dgCar_slideshow: [],
        dgCar_slidenum: 0,
        dgCar_merchantinfo: [],
        dgCar_hotcat: [],
        dgCar_current: 0,
        dgCar_articles: [],
        dgCar_options: {},
        dgCar_ConfigInfo: [],
        dgCar_img_url_yuyue: "http://www.ixiaochengxu.cc/resource/images/car/hall.png",
        dgCar_img_url_zaixian: "http://www.ixiaochengxu.cc/resource/images/car/bespeak.png",
        dgCar_img_url_shouhou: "http://www.ixiaochengxu.cc/resource/images/car/service.png",
        dgCar_shareInfo: {},
        config_options: []
    },
    onLoad: function(a) {
        this.setData({
            dgGlobal_options: a
        }), this.loadControlOptions(a);
    },
    loadControlOptions: function(a) {
        var e = this, i = this, n = r.duoguan_host_api_url + "/index.php/addon/DuoguanUser/Api/getCustomConfig";
        t.default.get(n, {
            id: 61515
        }, function(a) {
            i.setData({
                config_options: a
            }), i.parseVideoUrl(a), e.setData({
                dgCar_options: e.data.dgCar_options
            });
            var t = e.data.dgCar_options;
            e.dgCar_intslide(t), e.dgCar_getMerchant(t), e.dgCar_getHotCar(t), e.dgCar_getArticle(t), 
            e.dgCar_getConfigInfo(t);
        });
    },
    parseVideoUrl: function(a) {
        var e = this, i = [];
        for (var n in a) {
            var o = a[n];
            void 0 !== o.autoplay && void 0 !== o.src && i.push(o);
        }
        0 !== i.length && t.default.post(r.duoguan_host_api_url + "/index.php/home/utils/parseVideoUrls", {
            urls: JSON.stringify(i.map(function(a) {
                return a.src;
            }))
        }, function(t) {
            for (var r = 0; r < t.length; r++) {
                var n = t[r];
                i[r].src = n;
            }
            e.setData({
                config_options: a
            });
        });
    },
    onPullDownRefresh: function() {
        var a = this;
        a.onLoad(a.data.dgGlobal_options), setTimeout(function() {
            wx.stopPullDownRefresh();
        }, 1e3);
    },
    onShareAppMessage: function() {
        return {
            title: "汽车专卖4S店",
            desc: "新页面",
            imageUrl: "",
            path: "pages/custom/custom_652783744"
        };
    },
    onCallTap: function(a) {
        var t = a.currentTarget.dataset || a.target.dataset, r = t.mobile, e = t.tips;
        if (r) {
            var i = e || "你将要拨打电话：" + r;
            wx.showModal({
                title: "温馨提示",
                content: i,
                success: function(a) {
                    a.cancel || wx.makePhoneCall({
                        phoneNumber: r
                    });
                }
            });
        }
    },
    onNavigateTap: function(a) {
        var r = a.detail.target ? a.detail.target.dataset : a.currentTarget.dataset, e = r.url, i = r.type, n = r.appId;
        return r.invalid ? console.warn("链接已被禁用") : e ? (a.detail.formId && t.default.pushFormId(a.detail.formId), 
        void ("mini" === i ? wx.navigateToMiniProgram({
            appId: n,
            path: e,
            fail: function(a) {
                console.error(a);
            }
        }) : wx.navigateTo({
            url: e,
            fail: function() {
                wx.switchTab({
                    url: e
                });
            }
        }))) : console.warn("页面地址未配置");
    },
    onPreviewTap: function(a) {
        var t = a.target.dataset, r = t.index, e = t.url;
        if (void 0 !== r || void 0 !== e) {
            var i = a.currentTarget.dataset.urls;
            i = void 0 === i ? [] : i, void 0 === r || e || (e = i[r]), wx.previewImage({
                current: e,
                urls: i
            });
        }
    },
    dgCar_intslide: function(a) {
        var r = this;
        t.default.get(e.default.duoguan_host_api_url + "/index.php/addon/DuoguanCar/SlideshowApi/slideList.html", a, function(a) {
            r.setData({
                dgCar_slideshow: a.img_url,
                dgCar_slidenum: a.num
            });
        });
    },
    dgCar_ToUrl: function(a) {
        var t = a.currentTarget.dataset.url;
        i.default.navigateTo({
            url: "../webview/webview?url=" + t
        });
    },
    dgCar_getMerchant: function(a) {
        var r = this;
        t.default.post(e.default.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Api/getMerchant.html", a, function(a) {
            r.setData({
                dgCar_merchantinfo: a
            });
        });
    },
    dgCar_ToMerchant: function(a) {
        var t = a.currentTarget.dataset.id;
        i.default.navigateTo({
            url: "/pages/car/go-shop/go-shop?id=" + t
        });
    },
    dgCar_goCoupon: function() {
        i.default.navigateTo({
            url: "/pages/car/get-coupon/get-coupon"
        });
    },
    dgCar_getArticle: function(a) {
        var r = this;
        t.default.post(e.default.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Api/getArticle.html", a, function(a) {
            r.setData({
                dgCar_articles: a
            }), r.dgCar_startAd(a);
        });
    },
    dgCar_startAd: function(a) {
        var t = this;
        clearInterval(this.ad.timerId);
        var r = 0, e = (void 0 === a.ad_interval || a.ad_interval, function() {
            var e = {};
            e.abstract = a[r].abstract, e.notice_index = r, r = r >= a.length - 1 ? 0 : r + 1, 
            t.setData({
                dgCar_abstract: e.abstract
            });
        });
        this.ad.timerId = setInterval(e, 3e3), e();
    },
    dgCar_getHotCar: function(a) {
        var r = this, i = this.data.config_options["dg-car-list"].listNumber || 1;
        a.row = i, t.default.post(e.default.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Api/getHotCar.html", a, function(a) {
            r.setData({
                dgCar_hotcar: a
            });
        });
    },
    dgCar_getConfigInfo: function(a) {
        var r = this;
        t.default.post(e.default.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Api/getConfigInfo.html", a, function(a) {
            r.setData({
                dgCar_img_url_yuyue: a.img_url_yuyue ? a.img_url_yuyue : "http://www.ixiaochengxu.cc/resource/images/car/hall.png",
                dgCar_img_url_zaixian: a.img_url_zaixian ? a.img_url_zaixian : "http://www.ixiaochengxu.cc/resource/images/car/bespeak.png",
                dgCar_img_url_shouhou: a.img_url_shouhou ? a.img_url_shouhou : "http://www.ixiaochengxu.cc/resource/images/car/service.png",
                dgCar_ConfigInfo: a
            });
        });
    },
    dgCar_getcurrent: function(a) {
        var t = a.detail.current;
        this.setData({
            dgCar_current: t
        });
    },
    dgCar_callPhone: function(a) {
        var t = a.currentTarget.dataset.mobile;
        i.default.makePhoneCall({
            phoneNumber: t
        });
    },
    dgCar_goZhanting: function() {
        i.default.navigateTo({
            url: "/pages/car/display-hall/display-hall"
        });
    },
    dgCar_goZiXun: function() {
        i.default.navigateTo({
            url: "/pages/car/consult/consult"
        });
    },
    dgCar_gofuwu: function() {
        i.default.navigateTo({
            url: "/pages/car/customer-service/customer-service"
        });
    },
    dgCar_goArticle: function() {
        i.default.navigateTo({
            url: "/pages/car/news/news"
        });
    },
    dgCar_toCarInfo: function(a) {
        var t = a.currentTarget.dataset.id;
        i.default.navigateTo({
            url: "/pages/car/detail/detail?id=" + t
        });
    },
    dgCar_goCarInfo: function(a) {
        var t = a.currentTarget.dataset.url;
        i.default.navigateTo({
            url: t
        });
    }
});